/*!
// Testweb v0.4.0
// http://or-change.cn
// Copyright 2014 OrChange Inc. All rights reserved.
// Licensed under the GPL License.
*/
/*jslint vars: true, forin: true, plusplus: true */
/*global define: false */
/**
 * 数据字典方法
 * @module Dictionary
 * @requires randexp
 * @example
 *     var Dict = require("./oc.dict"); //How to require Dict module.
 */
define(function (require, exports, module) {
	'use strict';
	require("lib/core/randexp");
	var Entity = require("./entity");
	var Dictionary;
	/**
	 * Dict tool functions. Factory function.
	 * @class Dictionary.
	 */
	Dictionary = function Dictionary(options) {
		/**
		 * Cache a builder result in object.
		 * @property data
		 * @type object
		 */
		this.data = options.data;
		Entity.call(this, options);
	};
	Dictionary.prototype = new Entity();
	Dictionary.prototype.constructor = Dictionary;
	/**
	 * 获取一条数据
	 * @method getRow
	 * @param index {number}
	 * @returns row {object}
	 *		dictionary.getRow(0);
	 */
	Dictionary.prototype.getRow = function (index) {
		var key, row = {},
			data = this.data;
		for (key in data) {
			row[key] = data[key][index];
		}
		return row;
	};
	Dictionary.prototype.getLength = function () {
		var key;
		for (key in this.data) {
			return this.data[key].length;
		}
	};
	Dictionary.prototype.getKeys = function () {
		var key, keys = [];
		for (key in this.data) {
			keys.push({
				name: key
			});
		}

		return keys;
	};
	return Dictionary;
});